package com.inspur.jxpcxt.adapter;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.inspur.jxpcxt.bean.TeaEvaTeaInfo;
import com.inspur.jypcxt.R;

public class ShowTeaRankingAdapter extends BaseAdapter {
	private Context mContext = null;
	private LayoutInflater mLayoutInflater = null;
	List<TeaEvaTeaInfo> mData = new ArrayList<TeaEvaTeaInfo>();
	public ShowTeaRankingAdapter(Context context,List<TeaEvaTeaInfo> data) {
			this.mContext = context;
			mLayoutInflater = LayoutInflater.from(mContext);
			this.mData = data;
	}
	/**
	 * 包含多少个列表项
	 */
	@Override
	public int getCount()
		{
			// TODO Auto-generated method stub
			return mData.size();
		}
	/**
	 * 列表项内容
	 */
	@Override
	public Object getItem(int arg0)
		{
			// TODO Auto-generated method stub
			return null;
		}
	/**
	 * 列表项的ID
	 */
	@Override
	public long getItemId(int position)
		{
			// TODO Auto-generated method stub
			return position;
		}
	/**
	 * 返回值表示第position处的列表项组件
	 */
	@Override
	public View getView(int position, View convertView, ViewGroup parent)
		{
			ViewHolder viewHolder = null;
			if(convertView == null){
				convertView = mLayoutInflater.inflate(R.layout.item_teacher_ranking, parent, false);
				viewHolder = new ViewHolder();
				viewHolder.mRankingNumTv = (TextView) convertView.findViewById(R.id.tv_ranking_num);
				viewHolder.mRankingTnoTv = (TextView) convertView.findViewById(R.id.tv_ranking_tno);
				viewHolder.mRankingTnameTv = (TextView) convertView.findViewById(R.id.tv_ranking_tname);
				viewHolder.mRankingCnameTv = (TextView) convertView.findViewById(R.id.tv_ranking_cname);
				viewHolder.mRangkingAvgTv = (TextView) convertView.findViewById(R.id.tv_ranking_avg);
				
				convertView.setTag(viewHolder);
				
			}else{
				viewHolder = (ViewHolder) convertView.getTag();
			}
			//加载数据
			viewHolder.mRankingNumTv.setText(""+(position+1));
			viewHolder.mRankingTnoTv.setText("教师编号："+mData.get(position).getTno());
			viewHolder.mRankingTnameTv.setText("教师姓名："+mData.get(position).getTname());
			viewHolder.mRankingCnameTv.setText("课程名："+mData.get(position).getCname());
//			DecimalFormat   fnum   =   new   DecimalFormat("##0.00");  
//			  String   dd=fnum.format(scale);  
			viewHolder.mRangkingAvgTv.setText("平均分："+new DecimalFormat("##0.00").format(mData.get(position).getTeaAvg()));
			return convertView;
		}
class ViewHolder{
	private TextView mRankingNumTv = null;
	private TextView mRankingTnoTv = null;
	private TextView mRankingTnameTv = null;
	private TextView mRankingCnameTv = null;
	private TextView mRangkingAvgTv = null;
}
}
